package service;

import java.util.Collection;
import java.util.List;

import domain.DomainObject;
import exceptions.GeneralServiceException;

/**
 * This is a generic interface that exposes generic methods used mostly by all
 * services. This methods include CRUD operations with ability to get all
 * entity. If some service doesn't need to provide support for all such methods,
 * then it should not subclass this interface.
 * 
 * @author yuyok
 * 
 * @param <T>
 * Domain class to work with
 */
public interface IGenericService<T extends DomainObject> {

    /**
     * Deleting entity from database. Doing nothing if entity with passed id not
     * found.
     * 
     * @param id
     *            Unique id of the entity to delete
     * @throws GeneralServiceException
     *             If service fails to delete entity
     * @throws IllegalArgumentException
     *             If id is <code>null</code>
     */
    public void delEntityById(Long id)
            throws IllegalArgumentException, GeneralServiceException;

    public void delEntity(T entity)
            throws IllegalArgumentException, GeneralServiceException;

    public void delAllEntities(Collection<Long> ids)
            throws IllegalArgumentException, GeneralServiceException;

    public T getEntityById(Long id)
            throws IllegalArgumentException;

    public T save(T entity)
            throws IllegalArgumentException, GeneralServiceException;
}
